package bishiqiangxun;
//题目:最长回文子串
public class Test3 {
    private static int max1(String str,int left,int right) {
        //以中心点开始扩展
        while(left >= 0 && right < str.length() && str.charAt(left) == str.charAt(right)) {
            left--;
            right++;
        }
        return right - left -1;
    }
    public int getLongestPalindrome (String A) {
        int max = 1;
        int n = A.length();
        //遍历每一个点  假设每一个点都是中心下标
        for(int i = 0;i < n-1; i++) {
            max = Math.max(max,Math.max(max1(A,i,i),max1(A,i,i+1)));
        }
        return max;
    }
    public static void main(String[] args) {

    }
}
